//
//  MainViewController.swift
//  LJweiboSwift
//
//  Created by gaolijun on 15/7/20.
//  Copyright (c) 2015年 Lijun. All rights reserved.
//

//函数的重载


import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        addChildViewControllers()
        tabBar.tintColor = UIColor.orangeColor()
    }
    
    func addChildViewControllers(){
        addChildViewController("Home", "首页", "tabbar_home")
        addChildViewController("Message", "消息", "tabbar_message_center")
        addChildViewController("Discover", "发现", "tabbar_discover")
        addChildViewController("Profile", "我", "tabbar_message_center")
    }
    
    //在参数的名称前面加_表示可以省略前面的名称，＃表示在调用参数的时间必须写上前面的参数
    ///swift的一个特有的东西，就是函数的重载
    func addChildViewController(sbName:String,_ title:String,_ imageName:String) {
    let sb = UIStoryboard(name: sbName, bundle: nil)
    let nav = sb.instantiateInitialViewController() as! UINavigationController
    nav.title = title
    nav.topViewController.title = title
        nav.tabBarItem.image = UIImage(named:imageName)
    nav.tabBarItem.selectedImage = UIImage(named:imageName + "_highlighted")
    addChildViewController(nav)
    
    }

}
